home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / freyja_t.z / freyja_t / display.c < prev    next >
C/C++ Source or Header  |  1992-04-14  |  15KB  |  827 lines

  1. /* DISPLAY.C -- Redisplay and Display Routines
  2.  
  3.     Written March 1991 by Craig A. Finseth
  4.     Copyright 1991 by Craig A. Finseth
  5. */
  6.  
  7. #include "freyja.h"
  8.  
  9. #define WINMINHEIGHT    3
  10.  
  11. static char screen[ROWMAX][COLMAX + 1];
  12. static int screen_line_used[ROWMAX + 1] = { 0 };
  13. static int screen_line_len[ROWMAX + 1] = { 0 };
  14. static int point_row;
  15.  
  16. static char mode_flags[8];
  17.  
  18. static FLAG need_screen_range;
  19.  
  20. static int divide;
  21.  
  22. static char mode_buf[COLMAX + 1];
  23. static FLAG div_shown = FALSE;
  24. #if defined(MSDOS)
  25. static int jmenu_which = -1;
  26. static int jmenu_cols[] = { 0, 6, 12, 18 };
  27. #endif
  28.  
  29. void D_Clear();        /* int row */
  30. void D_ClearScreen();    /* void */
  31. void D_ClearWind();    /* struct window *wptr */
  32. void D_IncrDisplay();    /* FLAG nested_call */
  33. void D_IncrDisplay2();    /* FLAG nested_call */
  34. void D_IncrDisplay3();    /* void */
  35. int D_InnerDisplay();    /* struct window *wptr, struct mark *point */
  36. void D_InnerDisplay2();    /* struct window *wptr; int row */
  37. void D_ScreenRange();    /* FLAG nested_call */
  38.  
  39. /* ------------------------------------------------------------ */
  40.  
  41. /* Initialize the display routines, part 1. */
  42.  
  43. void
  44. DInit1()
  45.     {
  46.     int cnt;
  47.  
  48.     num_windows = 1;        /* one window at the top */
  49.     divide = TMaxRow() - 1;
  50.  
  51.     for (cnt = 0; cnt < NUMWINDOWS; cnt++) {
  52.         windows[cnt].visible = FALSE;
  53.         windows[cnt].sstart = NULL;
  54.         windows[cnt].send = NULL;
  55.         windows[cnt].point = NULL;
  56.         }
  57.  
  58.     windows[0].visible = TRUE;
  59.     windows[0].top = 0;
  60.     windows[0].bot = TMaxRow() - 2;
  61.     windows[0].isend = FALSE;
  62.     windows[0].offset = 0;
  63.  
  64.     cwin = &windows[0];
  65.     need_screen_range = TRUE;
  66.     }
  67.  
  68.  
  69. /* ------------------------------------------------------------ */
  70.  
  71. /* Initialize the display routines, part 2. */
  72.  
  73. void
  74. DInit2()
  75.     {
  76.     windows[0].sstart = BMarkCreate();
  77.     windows[0].send = BMarkCreate();
  78.     windows[0].point = BMarkCreate();
  79.     D_ClearScreen();
  80.     }
  81.  
  82.  
  83. /* ------------------------------------------------------------ */
  84.  
  85. /* Terminate the display routines. */
  86.  
  87. void
  88. DFini()
  89.     {
  90.     }
  91.  
  92.  
  93. /* ------------------------------------------------------------ */
  94.  
  95. /* Display a message in the echo line. */
  96.  
  97. void
  98. DEcho(msg)
  99.     char *msg;
  100.     {
  101.     TSetPoint(TMaxRow() - 1, 0);
  102.     THiOn();
  103.  
  104.     strncpy(mode_buf, msg, TMaxCol() + 1);
  105.     mode_buf[TMaxCol()] = NUL;
  106.     TPutStr(mode_buf);
  107.  
  108.     TCLEOL();
  109.     THiOff();
  110.     TForce();
  111.     }
  112.  
  113.  
  114. /* ------------------------------------------------------------ */
  115.  
  116. /* Display a message in the echo line, but don't move the cursor. */
  117.  
  118. void
  119. DEchoNM(msg)
  120.     char *msg;
  121.     {
  122.     int row;
  123.     int col;
  124.  
  125.     row = TGetRow();
  126.     col = TGetCol();
  127.     DEcho(msg);
  128.     TSetPoint(row, col);
  129.     TForce();
  130.     }
  131.  
  132.  
  133. /* ------------------------------------------------------------ */
  134.  
  135. /* Display an error message */
  136.  
  137. void
  138. DError(msg)
  139.     char *msg;
  140.     {
  141.     char buf[2 * COLMAX + 1];
  142.     int row;
  143.     int col;
  144.  
  145.     row = TGetRow();
  146.     col = TGetCol();
  147.  
  148.     xsprintf(buf, ">>> %s", msg);
  149.     DEcho(buf);
  150.  
  151.     TBell();
  152.     KGetChar();
  153.  
  154.     DModeLine();
  155.     TSetPoint(row, col);
  156.     TForce();
  157.     }
  158.  
  159.  
  160. /* ------------------------------------------------------------ */
  161.  
  162. /* Update the display from the buffer */
  163.  
  164. void
  165. DIncrDisplay()
  166.     {
  167.     int cnt;
  168.  
  169.     if (need_screen_range) {
  170.         D_ScreenRange(FALSE);
  171.         DModeLine();
  172.         }
  173.     if (num_windows > 1) {
  174.         if (!div_shown) {
  175.             div_shown = TRUE;
  176.             TSetPoint(divide, 0);
  177.             THiOn();
  178.             for (cnt = 0; cnt < TMaxCol(); ++cnt)
  179.                 TPutChar('-');
  180.             THiOff();
  181.             }
  182.         }
  183.     else    div_shown = FALSE;
  184.     D_IncrDisplay(FALSE);
  185.     }
  186.  
  187.  
  188. /* ------------------------------------------------------------ */
  189.  
  190. /* Put up the menu for the Jaguar version. */
  191.  
  192. #if defined(MSDOS)
  193. void
  194. DJMenus(which)
  195.     int which;
  196.     {
  197.     int cnt;
  198.  
  199.     D_Clear(0);
  200.     D_Clear(1);
  201.     D_Clear(2);
  202. #if !defined(SYSMGR)
  203.     jmenu_which = which;
  204.     if (jmenu_which < 0) return;
  205.  
  206.     TSetPoint(0, 0);
  207.     TPutStr("Help  Open  Save  Quit");
  208.     TCLEOL();
  209.  
  210.     TSetPoint(1, 0);
  211.     TCLEOL();
  212. #endif
  213.     TSetPoint(2, 0);
  214.     for (cnt = 0; cnt < TMaxCol(); ++cnt) TPutChar('\xcd');
  215.  
  216.     TSetPoint(0, jmenu_cols[which]);
  217.     }
  218. #endif
  219.  
  220.  
  221. /* ------------------------------------------------------------ */
  222.  
  223. /* Scroll the window left. */
  224.  
  225. void
  226. DLeft()
  227.     {
  228.     if (!isuarg) uarg = BGetCol() - (TMaxCol() - HOVERLAP);
  229.     if (uarg < 0) uarg = 0;
  230.     BMakeColF(uarg);
  231.     uarg = 0;
  232.     D_ClearWind(cwin);
  233.     }
  234.  
  235.  
  236. /* ------------------------------------------------------------ */
  237.  
  238. /* Display the mode flags */
  239.  
  240. void
  241. DModeFlags()
  242.     {
  243.     long loc;
  244.     long len;
  245.     int pct;
  246.     char buf[LINEBUFFSIZE];
  247.  
  248.      if (KIsKey() == 'Y') return;
  249.  
  250.     loc = BGetLocation();
  251.     len = BGetLength(cbuf);
  252.     if (len == 0) len = 1;
  253.     pct = (loc * 100) / len;
  254.  
  255.     xsprintf(buf, "%3d%% %c%c",
  256.             pct,
  257.             BIsMod(cbuf) ? '*' : ' ',
  258.             TabIsDelete(lastkey, lasttable) ? '+' : ' ');
  259.  
  260.     if (!strequ(mode_flags, buf)) {
  261.         TSetPoint(TMaxRow() - 1, 12);
  262.         THiOn();
  263.         TPutStr(buf);
  264.         THiOff();
  265.         xstrcpy(mode_flags, buf);
  266.         }
  267.     }
  268.  
  269.  
  270. /* ------------------------------------------------------------ */
  271.  
  272. /* Display the mode line */
  273.  
  274. void
  275. DModeLine()
  276.     {
  277.     char buf[2 * COLMAX + 1];
  278.  
  279.     TSetPoint(TMaxRow() - 1, 0);
  280.     xsprintf(buf, "Freyja V1.4 ###%% *+ %s", cbuf->fname);
  281.     TCLEOL();
  282.     *mode_flags = NUL;
  283.     DEcho(buf);
  284.     DModeFlags();
  285.     }
  286.  
  287.  
  288. /* ------------------------------------------------------------  */
  289.  
  290. /* Put a new display on the screen. */
  291.  
  292. void
  293. DNewDisplay()
  294.     {
  295.     TClrScreen();
  296.     D_ClearScreen();
  297.     D_ScreenRange(FALSE);
  298.     div_shown = FALSE;
  299.     DModeLine();
  300.     }
  301.  
  302.  
  303. /* ------------------------------------------------------------ */
  304.  
  305. /* Return the current preferred line. */
  306.  
  307. int
  308. DPrefLine()
  309.     {
  310.     return((PREF_PCT * DWindHeight()) / 100);
  311.     }
  312.  
  313.  
  314. /* ------------------------------------------------------------ */
  315.  
  316. /* Scroll the window right. */
  317.  
  318. void
  319. DRight()
  320.     {
  321.     if (!isuarg) uarg = BGetCol() + (TMaxCol() - HOVERLAP);
  322.     if (uarg < 0) uarg = 0;
  323.     BMakeColF(uarg);
  324.     uarg = 0;
  325.     D_ClearWind(cwin);
  326.     }
  327.  
  328.  
  329. /* ------------------------------------------------------------ */
  330.  
  331. /* Center redisplay */
  332.  
  333. void
  334. DScreenRange()
  335.     {
  336.     need_screen_range = TRUE;
  337.     }
  338.  
  339.  
  340. /* ------------------------------------------------------------ */
  341.  
  342. /* Toggle the visible gray flag. */
  343.  
  344. void
  345. DTogVisGray()
  346.     {
  347.     c.g.vis_gray = !c.g.vis_gray;
  348.     DNewDisplay();
  349.     }
  350.  
  351.  
  352. /* ------------------------------------------------------------ */
  353.  
  354. /* Display an informative message in the message area and wait for a
  355. key press. */
  356.  
  357. void
  358. DView(msg)
  359.     char *msg;
  360.     {
  361.     int row;
  362.     int col;
  363.  
  364.     row = TGetRow();
  365.     col = TGetCol();
  366.     DEcho(msg);
  367.     KGetChar();
  368.     DModeLine();
  369.     TSetPoint(row, col);
  370.     TForce();
  371.     }
  372.  
  373.  
  374. /* ------------------------------------------------------------ */
  375.  
  376. /* Grow the current window. */
  377.  
  378. void
  379. DWindGrow()
  380.     {
  381.     int height;
  382.     int cnt;
  383.  
  384.     if (num_windows <= 1) return;
  385.  
  386.     D_Clear(divide);
  387.     if (cwin > &windows[0]) {    /* move divider up */
  388.         height = (cwin - 1)->bot - (cwin - 1)->top + 1;
  389.         if (uarg > height - WINMINHEIGHT) uarg = height - WINMINHEIGHT;
  390.         if (uarg >= 1) {
  391.             for (cnt = (cwin - 1)->bot - uarg + 1;
  392.                  cnt < (cwin - 1)->bot; cnt++) {
  393.                 D_Clear(cnt);
  394.                 }
  395.             divide -= uarg;
  396.             (cwin - 1)->bot -= uarg;
  397.             cwin->top -= uarg;
  398.             }
  399.         }
  400.     else    {            /* move divider down */
  401.         height = (cwin + 1)->bot - (cwin + 1)->top + 1;
  402.         if (uarg > height - WINMINHEIGHT) uarg = height - WINMINHEIGHT;
  403.         if (uarg >= 1) {
  404.             for (cnt = (cwin + 1)->top;
  405.                  cnt < (cwin + 1)->top + uarg - 1; cnt++) {
  406.                 D_Clear(cnt);
  407.                 }
  408.             divide += uarg;
  409.             cwin->bot += uarg;
  410.             (cwin + 1)->top += uarg;
  411.             }
  412.         }
  413.     div_shown = FALSE;
  414.     DModeLine();
  415.     uarg = 0;
  416.     }
  417.  
  418.  
  419. /* ------------------------------------------------------------ */
  420.  
  421. /* Return the height of the current window */
  422.  
  423. int
  424. DWindHeight()
  425.     {
  426.     return(cwin->bot - cwin->top + 1);
  427.     }
  428.  
  429.  
  430. /* ------------------------------------------------------------ */
  431.  
  432. /* Switch to one window mode. */
  433.  
  434. void
  435. DWindOne()
  436.     {
  437.     struct window *wptr;
  438.  
  439.     if (num_windows <= 1) return;
  440.  
  441.     wptr = (cwin == &windows[0]) ? &windows[1] : &windows[0];
  442.     wptr->visible = FALSE;
  443.  
  444.     BMarkDelete(wptr->sstart);
  445.     BMarkDelete(wptr->send);
  446.     BMarkDelete(wptr->point);
  447.  
  448.     D_ClearWind(wptr);
  449.     D_Clear(divide);
  450.  
  451.     num_windows = 1;
  452.     cwin->top = 0;
  453.     cwin->bot = TMaxRow() - 2;
  454.     DScreenRange();
  455.     }
  456.  
  457.  
  458. /* ------------------------------------------------------------ */
  459.  
  460. /* Switch which window we are in. */
  461.  
  462. void
  463. DWindSwap()
  464.     {
  465.     if (num_windows <= 1) return;
  466.  
  467.     BMarkToPoint(cwin->point);
  468.     cwin = (cwin == &windows[0]) ? &windows[1] : &windows[0];
  469.     BPointToMark(cwin->sstart);
  470.     BMarkToPoint(cwin->send);
  471.     BPointToMark(cwin->point);
  472.     cwin->isend = FALSE;
  473.     DScreenRange();
  474.     }
  475.  
  476.  
  477. /* ------------------------------------------------------------ */
  478.  
  479. /* Toggle between one and two window mode. */
  480.  
  481. void
  482. DWindTog()
  483.     {
  484.     if (num_windows == 1)
  485.         DWindTwo();
  486.     else    DWindOne();
  487.     }
  488.  
  489.  
  490. /* ------------------------------------------------------------ */
  491.  
  492. /* Switch to two window mode. */
  493.  
  494. void
  495. DWindTwo()
  496.     {
  497.     struct window *wptr;
  498.  
  499.     if (num_windows > 1) return;
  500.  
  501.     wptr = (cwin == &windows[0]) ? &windows[1] : &windows[0];
  502.     wptr->visible = TRUE;
  503.  
  504.     divide = (TMaxRow() - 2) / 2;
  505.     cwin->top = 0;
  506.     cwin->bot = divide - 1;
  507.     wptr->top = divide + 1;
  508.     wptr->bot = TMaxRow() - 2;
  509.     wptr->offset = cwin->offset;
  510.  
  511.     D_ClearWind(wptr);
  512.  
  513.     wptr->point = BMarkCreate();
  514.     BMarkSwap(cwin->sstart);
  515.     wptr->sstart = BMarkCreate();
  516.     wptr->send = BMarkCreate();
  517.     wptr->isend = FALSE;
  518.     BMarkSwap(cwin->sstart);
  519.  
  520.     num_windows = 2;
  521.     DScreenRange();
  522.     }
  523.  
  524.  
  525. /* ------------------------------------------------------------ */
  526.  
  527. /* Switch to two window mode, but go to the other window. */
  528.  
  529. void
  530. DWindTwoO()
  531.     {
  532.     DWindTwo();
  533.     DWindSwap();
  534.     }
  535.  
  536.  
  537. /* ------------------------------------------------------------ */
  538.  
  539. /* Clear the row. */
  540.  
  541. void
  542. D_Clear(row)
  543.     int row;
  544.     {
  545.     BMarkSetMod(BMarkScreen(row));
  546.     screen_line_len[row] = 0;
  547.     screen_line_used[row] = TMaxCol() + 1;
  548.     }
  549.  
  550.  
  551.  
  552. /* ------------------------------------------------------------ */
  553.  
  554. /* Clear the screen. */
  555.  
  556. void
  557. D_ClearScreen()
  558.     {
  559.     int cnt;
  560.  
  561.     for (cnt = 0; cnt < TMaxRow() - 1; cnt++) {
  562.         D_Clear(cnt);
  563.         }
  564.     }
  565.  
  566.  
  567. /* ------------------------------------------------------------ */
  568.  
  569. /* Clear the window. */
  570.  
  571. void
  572. D_ClearWind(wptr)
  573.     struct window *wptr;
  574.     {
  575.     int cnt;
  576.  
  577.     for (cnt = wptr->top; cnt <= wptr->bot; cnt++) {
  578.         D_Clear(cnt);
  579.         }
  580.     }
  581.  
  582.  
  583. /* ------------------------------------------------------------ */
  584.  
  585. /* Actually update the display from the buffer */
  586.  
  587. void
  588. D_IncrDisplay(nested_call)
  589.     FLAG nested_call;
  590.     {
  591.     struct window *wptr;
  592.     int cnt;
  593.     FLAG ischanged = FALSE;
  594.  
  595.     cnt = BGetCol();
  596.     while (cnt < cwin->offset) {
  597.         cwin->offset -= TMaxCol() - HOVERLAP;
  598.         if (cwin->offset < 0) cwin->offset = 0;
  599.         ischanged = TRUE;
  600.         }
  601.     while (cnt >= cwin->offset + TMaxCol()) {
  602.         cwin->offset += TMaxCol() - HOVERLAP;
  603.         ischanged = TRUE;
  604.         }
  605.     if (ischanged) D_ClearWind(cwin);
  606.  
  607.     BPushState();
  608.     if (BMarkBuf(cwin->sstart) != cbuf || BIsBeforeMark(cwin->sstart) ||
  609.          (cwin->isend && BMarkBuf(cwin->send) == cbuf &&
  610.          !BIsBeforeMark(cwin->send))) {
  611.         D_ScreenRange(nested_call);
  612.         }
  613.  
  614.     BMarkToPoint(cwin->point);
  615.     BPointToMark(cwin->sstart);
  616.     cwin->isend = FALSE;
  617.     point_row = D_InnerDisplay(cwin, cwin->point);
  618.  
  619.     if (BIsBeforeMark(cwin->point) && KIsKey() != 'Y') {
  620.         D_IncrDisplay2(nested_call);
  621.         }
  622.     else    {
  623.         if (num_windows > 1) {
  624.             wptr = (cwin == &windows[0]) ? &windows[1] :
  625.                 &windows[0];
  626.             BPointToMark(wptr->sstart);
  627.             D_InnerDisplay(wptr, NULL);
  628.             }
  629.         D_IncrDisplay3();
  630.         }
  631.     }
  632.  
  633.  
  634. /* ------------------------------------------------------------ */
  635.  
  636. /* Inner part of IncrDisplay. */
  637.  
  638. void
  639. D_IncrDisplay2(nested_call)
  640.     FLAG nested_call;
  641.     {
  642.     BPointToMark(cwin->point);
  643.     D_ScreenRange(nested_call);
  644.     BPopState();
  645.     D_IncrDisplay(TRUE);
  646.     }
  647.  
  648.  
  649. /* ------------------------------------------------------------ */
  650.  
  651. /* Inner part of IncrDisplay. */
  652.  
  653. void
  654. D_IncrDisplay3()
  655.     {
  656.     int col;
  657.  
  658.     BPointToMark(cwin->point);
  659.     BPopState();
  660.     DModeFlags();
  661.     col = BGetCol() - cwin->offset;
  662.     if (col < 0) col = 0;
  663.     if (col >= TMaxCol()) col = TMaxCol() - 1;
  664.     TSetPoint(point_row, col);
  665.     }
  666.  
  667.  
  668. /* ------------------------------------------------------------ */
  669.  
  670. /* Display one window. */
  671.  
  672. int
  673. D_InnerDisplay(wptr, point)
  674.     struct window *wptr;
  675.     struct mark *point;
  676.     {
  677.     struct mark *mptr;
  678.     int row;
  679.     FLAG need_pnt = TRUE;
  680.  
  681. #if defined(MSDOS)
  682.     if (c.g.special == 'J') JDisStart();
  683. #endif
  684.     for (row = wptr->top; row <= wptr->bot && KIsKey() != 'Y'; ++row) {
  685.         mptr = BMarkScreen(row);
  686.         if (BMarkBuf(mptr) != cbuf || BMarkIsMod(mptr) ||
  687.              !BIsAtMark(mptr)) {
  688.             BMarkToPoint(mptr);
  689.             D_InnerDisplay2(wptr, row);
  690.             }
  691.         else    BPointToMark(BMarkScreen(row + 1));
  692.  
  693.         if (point != NULL && need_pnt && BMarkBuf(point) == cbuf &&
  694.              BIsAfterMark(point)) {
  695.             point_row = row;
  696.             need_pnt = FALSE;
  697.             }
  698.         }
  699.  
  700.     mptr = BMarkScreen(row);
  701.     if (BMarkBuf(mptr) != cbuf || !BIsAtMark(mptr)) BMarkSetMod(mptr);
  702.     BMarkToPoint(mptr);
  703.     if (point != NULL) {
  704.         if (KIsKey() != 'Y') {
  705.             wptr->isend = TRUE;
  706.             BMarkToPoint(wptr->send);
  707.             }
  708.         if (need_pnt) point_row = wptr->bot + 1;
  709.         }
  710. #if defined(MSDOS)
  711.     if (c.g.special == 'J') JDisEnd();
  712. #endif
  713.     return(point_row);
  714.     }
  715.  
  716.  
  717. /* ------------------------------------------------------------ */
  718.  
  719. /* Inner loop of InnerDisplay. */
  720.  
  721. void
  722. D_InnerDisplay2(wptr, row)
  723.     struct window *wptr;
  724.     int row;
  725.     {
  726.     int maxcol = TMaxCol();
  727.     int maxoff = maxcol + wptr->offset;
  728.     int col;
  729.     int chr;
  730.     char *srptr;
  731.     char *cptr;
  732.     int *sllptr;
  733.     int *sluptr;
  734.  
  735.     srptr = screen[row];
  736.     sllptr = &screen_line_len[row];
  737.     sluptr = &screen_line_used[row];
  738.  
  739.     cptr = srptr;
  740.     col = 0;
  741.  
  742.     while (cptr - srptr < *sllptr && !BIsEnd() &&
  743.          (chr = BGetChar()) != NL && chr != SNL) {
  744.         if (col >= wptr->offset) {
  745.             if (chr != *cptr) break;
  746.             *cptr++;
  747.             }
  748.         if (chr >= SP && chr <= '~')
  749.             col += 1;
  750.         else    col += TGetWidth(chr, col);
  751.         BMoveBy(1);
  752.         }
  753.  
  754.     TSetPoint(row, col > wptr->offset ? col - wptr->offset : 0);
  755.     TSetOffset(wptr->offset);
  756.     if (*sluptr <= maxcol) TAdjCol();
  757.  
  758.     while (!BIsEnd() && (chr = BGetChar()) != NL && chr != SNL &&
  759.          col < maxoff) {
  760.         if (col >= wptr->offset) *cptr++ = chr;
  761.         TPutChar(chr);
  762.         if (chr >= SP && chr <= '~')
  763.             col += 1;
  764.         else    col += TGetWidth(chr, col);
  765.         BMoveBy(1);
  766.         }
  767.     if (c.g.vis_gray && !BIsEnd() && BGetChar() == NL && col < maxoff) {
  768.         if (col >= wptr->offset) *cptr++ = VIS_NL_CHAR;
  769.         TPutChar(VIS_NL_CHAR);
  770.         col += TGetWidth(VIS_NL_CHAR, col);
  771.         }
  772.  
  773.     TSetOffset(0);
  774.  
  775.     col -= wptr->offset;
  776.     if (col < 0) col = 0;
  777.     if (col > maxcol) col = maxcol;
  778.     TSetPoint(row, col);
  779.  
  780.     if (col < *sluptr || *sllptr > cptr - srptr) TCLEOL();
  781.     *sllptr = cptr - srptr;
  782.     *sluptr = col;
  783.  
  784.     if (TGetCol() < maxcol) {
  785.         if (BIsEnd())
  786.             BInvalid();
  787.         else if (!IsNL())
  788.             SearchNLF();
  789.         else    BMoveBy(1);
  790.         }
  791.     else    {
  792.         if (!IsNL())
  793.             SearchNLF();
  794.         else    BMoveBy(1);
  795.         }
  796.     }
  797.  
  798.  
  799. /* ------------------------------------------------------------ */
  800.  
  801. /* Do the work for centering the display. */
  802.  
  803. void
  804. D_ScreenRange(nested_call)
  805.     FLAG nested_call;
  806.     {
  807.     int cnt;
  808.     int pref = DPrefLine();
  809.  
  810.     need_screen_range = FALSE;
  811.     cwin->isend = FALSE;
  812.  
  813.     BMarkToPoint(cwin->point);
  814.     if (nested_call) {
  815.         for (cnt = 0; cnt < pref + 1 && SearchNLB(); ++cnt) ;
  816.         }
  817.     else    {
  818.         for (cnt = 0; cnt < pref; ++cnt) SearchNLB();
  819.         }
  820.     CLineA();
  821.     BMarkToPoint(cwin->sstart);
  822.     BPointToMark(cwin->point);
  823.     }
  824.  
  825.  
  826. /* end of DISPLAY.C -- Redisplay and Display Routines */
  827.